﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Generator
{
    /// <summary>
    /// This class provides a function generator for the real Beta function.
    /// </summary>
    [Serializable]
    public class BetaFunctionGenerator : AbstractTwoParameterFunctionGenerator
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BetaFunctionGenerator"/> class.
        /// </summary>
        /// <param name="firstInterval">The first interval of the function generator.</param>
        /// <param name="secondInterval">The second interval of the function generator.</param>
        public BetaFunctionGenerator(double firstInterval, double secondInterval)
            : base(firstInterval, secondInterval)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BetaFunctionGenerator"/> class.
        /// </summary>
        /// <param name="firstInterval">The first interval of the function generator.</param>
        /// <param name="secondInterval">The second interval of the function generator.</param>
        /// <param name="startvalue">The start value of the function generator.</param>
        public BetaFunctionGenerator(double firstInterval, double secondInterval, double startvalue)
            : base(firstInterval, secondInterval, startvalue)
        {
        }

        /// <summary>
        /// Calculates the next value by using the beta function.
        /// </summary>
        /// <returns>The calculated value of the generator.</returns>
        public override double NextValue()
        {
            double result = SpecialFunctions.BetaFunction(this.currentValue, this.secondCurrentValue);

            this.currentValue += this.FirstInterval;
            this.secondCurrentValue += this.SecondInterval;

            return result;
        }
    }
}